import request from '@/utils/request'

export default {
  register(data:any){
    return request({
      url: '/user/register',
      method: 'post',
      data
    })
  },
  sendCode(data:any){
    return request({
      url: `/user/sendCode?phone=${data}`,
      method: 'post',
    })
  },
  resetPassword(data:any){
    return request({
      url: `/user/resetPassword?phone=${data.phone}&newPassword=${data.newPassword}&code=${data.code}`,
      method: 'post',
    })
  },
  login(data:any){
    return request({
      url: '/user/login',
      method: 'post',
      data
    })
  },
  loginout(){
    return request({
      url: '/user/logout',
      method: 'post'
    })
  },
  bindPhone(data:any){
    return request({
      url: '/user/bindPhone',
      method: 'put',
      data
    })
  },

  /**
 * 微信登录前置数据获取
 */
  getWXLoginData(){
    return request({
      url: '/getLoginParam',
      method: 'get'
    })
  },
  /**
   * 获取微信登录的 access_token
   */
  getWXLoginToken(appid, secret, code){
    return request({
      url: '/sys/wxlogin/access_token',
      method: 'get',
      params: {
        appid,
        secret,
        code
      }
    })
  },
  /**
   * 获取微信登录的 用户数据
   */
  getWXLoginUserInfo(accessToken, openid){
    return request({
      url: '/sys/wxlogin/userinfo',
      method: 'get',
      params: {
        accessToken,
        openid
      }
    })
  },
  /**
   * 获取微信登录的 用户数据
   */
  getLoginUserInfo(){
    return request({
      url: '/user/getMyUserInfo',
      method: 'get'
    })
  },

  updatePassword(data:any){
    return request({
      url: '/user/resetPassword',
      method: 'post',
      data
    })
  },
  // 
}

